package com.aistar.service.impl;

import com.aistar.mapper.MemberMapper;
import com.aistar.pojo.Member;
import com.aistar.pojo.MemberExample;
import com.aistar.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberServiceImpl implements MemberService {
    @Autowired
    private MemberMapper memberMapper;

    @Override
    public Member getbyId(int id) {
        return memberMapper.selectByPrimaryKey(id);//通过用户id来查询用户全部信息
    }

    @Override
    public Member getbyACC(String acc) {
        //通过用户账号来查找用户全部信息
        MemberExample example = new MemberExample();
       MemberExample.Criteria criteria = example.createCriteria();
       criteria.andUserAccountEqualTo(acc);
       List<Member> member =memberMapper.selectByExample(example);
        return member.get(0);
    }

    @Override
    public int updatestate(int userId) {
       Member member= memberMapper.selectByPrimaryKey(userId);
       member.setUserStatus(0);
       int Y=memberMapper.updateByPrimaryKey(member);
        return 0;
    }


}
